package app.common.utils.cjt.ao;

import com.alibaba.fastjson.annotation.JSONField;
import com.qimencloud.api.scene3ldsmu02o9.request.WdtWmsStockoutSalesQuerywithdetailRequest;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 销售出库单查询
 * @author feizns
 * @since 2023/04/06
 */
@Data
public class WmsStockoutSalesQueryWithDetailAo {

    /**
     * 开始时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime start_time;

    /**
     * 结束时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime end_time;

    /**
     * 出库单状态: 默认值为0
     * 1.已取消
     *
     * 2.在企业版状态中对应status=55(已确认),这里为 待分配~延时发货（此条件会返回延时发货状态的订单）
     *
     * 3.按照指定的status状态字段查询
     *
     * 0.延时发货&已完成
     */
    private Integer status_type = 0;

    /**
     *
     *
     * 传status_type=3情况下，按照修改时间和status查询
     *
     * （status_type=3的情况下，若不传status字段，按照发货时间查询）
     *
     * 出库单状态（若多个状态则以“，”隔开）:
     *
     * 110已完成
     */
    private String status = "110";

    /**
     * 不缺货
     */
    private String stockout_no;

    public WmsStockoutSalesQueryWithDetailAo(LocalDateTime start_time) {
        this.start_time = start_time;
        this.end_time = start_time.plusHours(1);
        if ( this.end_time.isAfter(LocalDateTime.now()) )
            this.end_time = LocalDateTime.now();
    }

    public WmsStockoutSalesQueryWithDetailAo(LocalDateTime start_time, LocalDateTime end_time) {
        this.start_time = start_time;
        this.end_time = end_time;
    }

    /**
     * 对参数
     * @return {@link WdtWmsStockoutSalesQuerywithdetailRequest.Params}
     */
    public WdtWmsStockoutSalesQuerywithdetailRequest.Params toParams() {
        WdtWmsStockoutSalesQuerywithdetailRequest.Params params = new WdtWmsStockoutSalesQuerywithdetailRequest.Params();
        params.setStartTime(this.start_time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        params.setEndTime(this.end_time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        params.setStatus(status);
        params.setStatusType(Long.valueOf(status_type));
        return params;
    }

}
